<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ include file="../general/header.jsp"%>
<div id="header"><c:choose>
	<c:when test="${opcode == 0 }">My Purchases</c:when>
	<c:otherwise>My Sales</c:otherwise>
</c:choose></div>
<%@ include file="../general/menu.jsp"%>
<div id="content">
<div>
<table class="listas">
	<tr style="font-weight: bold;">
		<td>Name</td>
		<td><c:choose>
			<c:when test="${opcode == 0 }">
								Owner
							</c:when>
			<c:otherwise>
								Buyer
							</c:otherwise>
		</c:choose></td>

		<td>Category</td>
		<td>Price</td>
		<td>Amount</td>
		<td>Bought Date</td>
		<td>Status</td>
	</tr>
	<c:if test="${not empty history}">
		<c:forEach var="purchase" items="${history}">
			<tr>
				<td><a
					href="../item/itemDetail?itemid=<c:out value='${purchase.item.id}' /> "><c:out
					value="${purchase.item.name}" /> </a></td>
				<td><c:choose>
					<c:when test="${opcode == 0 }">
						<a
							href="../user/viewProfile?userid=<c:out value='${purchase.item.user.id}' />"><c:out
							value="${purchase.item.user.name}" /></a>
					</c:when>
					<c:otherwise>
						<a
							href="../user/viewProfile?userid=<c:out value='${purchase.user.id}' />"><c:out
							value="${purchase.user.name}" /></a>
					</c:otherwise>
				</c:choose></td>
				<td><c:out value="${purchase.item.category.name}" /></td>
				<td><c:out value="${purchase.price}" /></td>
				<td><c:out value="${purchase.qty}" /></td>
				<td><fmt:formatDate type="date" value="${purchase.purchaseDate}" /></td>
				<c:if test="${opcode == 0}">
					<c:choose>
						<c:when
							test="${purchase.confirmation.buyerConfirmation == 'notyetconfirm' }">
							<td><a
								href="../purchase/confirmationBuyer?purchaseId=${purchase.id}">
								${purchase.confirmation.buyerConfirmation}</a></td>
						</c:when>
						<c:otherwise>
							<td>${purchase.confirmation.buyerConfirmation}</td>
						</c:otherwise>
					</c:choose>
				</c:if>
				<c:if test="${opcode == 1}">
					<c:choose>
						<c:when
							test="${purchase.confirmation.sellerConfirmation == 'notyetconfirm' }">
							<td><a
								href="../purchase/confirmationSeller?purchaseId=${purchase.id}">${purchase.confirmation.sellerConfirmation}
							</a></td>
						</c:when>
						<c:otherwise>
							<td>${purchase.confirmation.sellerConfirmation}</td>
						</c:otherwise>
					</c:choose>
				</c:if>
			</tr>
		</c:forEach>
	</c:if>
</table>
</div>
</div>
<br />
<a href="../general/index">Go Back to Index</a>
<script type="text/javascript">
	hideDirection();
</script>
<%@ include file="../general/footer.jsp"%>
